package com.oisix.oisystemts2.service.hassou;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

import java.io.IOException;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;

import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.oisix.common.TestDB;
import com.oisix.common.TestData;
import com.oisix.common.TestEnvironment;
import com.oisix.oisystemec.exception.BusinessException;
import com.oisix.oisystemec.model.Juchuu;
import com.oisix.oisystemec.model.Juchuumeisai;
import com.oisix.oisystemec.model.Kokyaku;
import com.oisix.oisystemec.model.Shouhin;
import com.oisix.oisystemec.model.Tantousha;
import com.oisix.oisystemec.model.Todokesaki;
import com.oisix.oisystemec.model.TodokesakiPK;
import com.oisix.oisystemec.model.Todoufuken;
import com.oisix.oisystemec.model.Yuubinbangou;
import com.oisix.oisystemfr.util.DateUtil;
import com.oisix.oisystemts2.service.hassou.Hassou1Csv.Fields;

public class Hassou1CsvTest {
    private static TestData testData;
    private static TimeZone t = TimeZone.getDefault();

    @BeforeClass
    public static void prepare() {
        TestEnvironment.prepare();

        // system property
        System.setProperty("wellnetCodeForBarCode", "08174");
        System.setProperty("combiniCompanyCode.oisix", "020236");
        System.setProperty("wellnetCodeForEAN128", "908174");

        testData = new TestData("src/com/oisix/oisystemts2/service/hassou/Hassou1CsvTest.xls");
        testData.load();
        TimeZone.setDefault(TimeZone.getTimeZone("JST"));
        System.clearProperty("oisix.test.date");
        System.clearProperty("oisix.test.junit_date");
    }

    @After
    public void tearDown() throws Exception {
        // testCreateData_processSeikyuuIdAndBarcode_ikkaiConveni
        TestDB.removeData("TBL_JUCHUU", "JUCHUU_ID=\'1\'");
        TimeZone.setDefault(t);
    }

    @AfterClass
    public static void cleanUp() {
        System.clearProperty("wellnetCodeForBarCode");
        System.clearProperty("combiniCompanyCode");
        System.clearProperty("wellnetCodeForEAN128");

        testData.cleanup();
        testData = null;
    }

    @Test
    public void testCreateData_normal(){
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setCoolryou(new BigDecimal(0));

        
        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            
            assertThat(result[Fields.JUCHUU_ID.ordinal()], is("juchuuId"));
            assertThat(result[Fields.SEIKYUU_ID.ordinal()], is(""));
            assertThat(result[Fields.KOKYAKU_ID.ordinal()], is("kokyakuId"));
            assertThat(result[Fields.KOKYAKUSHIMEI.ordinal()], is("shimei"));
            assertThat(result[Fields.KOKYAKUYUUBINBANGOU.ordinal()], is(""));
            assertThat(result[Fields.KOKYAKUTODOUFUKEN_ID.ordinal()], is("埼玉県"));
            assertThat(result[Fields.KOKYAKUADDR1.ordinal()], is(""));
            assertThat(result[Fields.KOKYAKUADDR2.ordinal()], is(""));
            assertThat(result[Fields.KOKYAKUTEL.ordinal()], is(""));
            assertNull(result[Fields.TODOKESAKISHIMEI.ordinal()]);
            assertThat(result[Fields.TODOKESAKIYUUBINBANGOU.ordinal()], is(""));
            assertThat(result[Fields.TODOKESAKITODOUFUKEN_ID.ordinal()], is(""));
            assertThat(result[Fields.TODOKESAKIADDR1.ordinal()], is(""));
            assertThat(result[Fields.TODOKESAKIADDR2.ordinal()], is(""));
            assertThat(result[Fields.TODOKESAKITEL.ordinal()], is(""));
            assertThat(result[Fields.SHOUHINDAIKIN.ordinal()], is("0"));
            assertThat(result[Fields.SOURYOU.ordinal()], is("0"));
            assertThat(result[Fields.COOLRYOUREITOURYOU.ordinal()], is("0"));
            assertThat(result[Fields.KESSAITESUURYOU.ordinal()], is(""));
            assertThat(result[Fields.NEBIKI.ordinal()], is(""));
            assertThat(result[Fields.NEMASHI.ordinal()], is(""));
            assertThat(result[Fields.SHIYOUPOINTO.ordinal()], is("0"));
            assertThat(result[Fields.SEIKYUUKINGAKU.ordinal()], is(""));
            assertThat(result[Fields.SHIHARAIKIGEN.ordinal()], is("2014/01/11"));
            assertThat(result[Fields.KESSAI_ID.ordinal()], is("0"));
            assertThat(result[Fields.MATSUJIME_FLG.ordinal()], is("1"));
            assertThat(result[Fields.HASSOU_YEAR.ordinal()], is("2014"));
            assertThat(result[Fields.HASSOU_MONTH.ordinal()], is("1"));
            assertThat(result[Fields.HASSOU_DAY.ordinal()], is("1"));
            assertThat(result[Fields.TOUTYAKU_YEAR.ordinal()], is("2014"));
            assertThat(result[Fields.TOUTYAKU_MONTH.ordinal()], is("1"));
            assertThat(result[Fields.TOUTYAKU_DAY.ordinal()], is("1"));
            assertThat(result[Fields.CSVTOUTYAKUJIKAN.ordinal()], is("10"));

            assertThat(result[Fields.BARCODE1.ordinal()], is(""));
            assertThat(result[Fields.BARCODE2.ordinal()], is(""));
            assertThat(result[Fields.BARCODE3.ordinal()], is(""));
            assertThat(result[Fields.BARCODE4.ordinal()], is(""));
            assertThat(result[Fields.YAMATOCODE0.ordinal()], is(""));
            assertThat(result[Fields.YAMATOCODE1.ordinal()], is(""));
            assertThat(result[Fields.SEIKYUUSHO_FLG.ordinal()], is("0"));
            assertThat(result[Fields.YAMATODENPYOUKUBUN.ordinal()], is("1"));
            assertNull(result[Fields.TOMEOKIBASHO.ordinal()]);
            assertNull(result[Fields.BIKOU.ordinal()]);
            assertThat(result[Fields.KASANPOINTO.ordinal()], is("0"));
            assertThat(result[Fields.GENZAIPOINTO.ordinal()], is("0"));
            assertThat(result[Fields.SEIKYUUKINGAKU0.ordinal()], is(""));
            assertThat(result[Fields.SEIKYUUKINGAKU1.ordinal()], is(""));
            assertThat(result[Fields.SEIKYUUKINGAKU2.ordinal()], is(""));
            assertThat(result[Fields.SEIKYUUKINGAKU3.ordinal()], is(""));
            assertThat(result[Fields.SEIKYUUKINGAKU4.ordinal()], is(""));
            assertThat(result[Fields.SEIKYUUKINGAKU5.ordinal()], is(""));
            assertThat(result[Fields.SEIKYUUKINGAKU6.ordinal()], is(""));
            assertThat(result[Fields.SEIKYUUKINGAKU7.ordinal()], is(""));
            assertThat(result[Fields.JIHIKI_FLG.ordinal()], is("0"));
            assertThat(result[Fields.SEIKYUUSAKI_FLG.ordinal()], is("0"));
            assertThat(result[Fields.ONOFF_FLG.ordinal()], is("0"));
            assertThat(result[Fields.INDEX.ordinal()], is("0"));
            assertThat(result[Fields.SHOUHIZEI.ordinal()], is("0"));
            assertThat(result[Fields.JITAKU_FLG.ordinal()], is("0"));
            assertThat(result[Fields.OCR1.ordinal()], is(""));
            assertThat(result[Fields.OCR2.ordinal()], is(""));
            assertThat(result[Fields.REITOU_JUCHUU_FLG.ordinal()], is("0"));
            assertThat(result[Fields.PRIORITY.ordinal()], is("100"));
            assertThat(result[Fields.SHOUHIN_DISCOUNT.ordinal()], is("0"));
            assertThat(result[Fields.COOL_DISCOUNT.ordinal()], is("0"));
            assertThat(result[Fields.SOURYOU_DISCOUNT.ordinal()], is("0"));
            assertThat(result[Fields.BARCODE_EAN.ordinal()], is(""));
            assertThat(result[Fields.HACCHUU_AUTONO.ordinal()], is(""));
            assertThat(result[Fields.NOSHI_NAME_INSERT.ordinal()], is(""));
            
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_normal_shouhizei_notnull() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setShouhizei(new BigDecimal(1));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result;
            result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.SHOUHIZEI.ordinal()], is("1"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateEmptyData() {
        Hassou1Csv hassou1Csv = new Hassou1Csv();
        String[] result = hassou1Csv.createEmptyData("1", 0);
        assertThat(result[Fields.JUCHUU_ID.ordinal()], is("1"));
        assertThat(result[Fields.INDEX.ordinal()], is("0"));
    }

    @Test
    public void testCreateData_getDateValue_null() {
        /* "date" can not be null */
        // Juchuu
        Juchuu juchuu = createJuchuu();
//        juchuu.setHassouyoteiDate(null); // NullPointerException
//        juchuu.setToutyakuyoteiDate(null); // NullPointerException

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
//            assertThat(result[Fields.HASSOU_YEAR.ordinal()], is(StringUtils.EMPTY));
//            assertThat(result[Fields.TOUTYAKU_YEAR.ordinal()], is(StringUtils.EMPTY));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getKokyakuYuubinbangou_hyphen() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.getKokyaku().setYuubinbangou("1234");

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.KOKYAKUYUUBINBANGOU.ordinal()], is("123-4"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getTodokesakiYuubinbangou_hyphen() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        Yuubinbangou yuubinbangou = new Yuubinbangou();
        yuubinbangou.setYuubinbangou("1234");
        yuubinbangou.setYamatoeigyoushoId("yamato");
        juchuu.getTodokesaki().setYuubinbangou(yuubinbangou);

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.TODOKESAKIYUUBINBANGOU.ordinal()], is("123-4"));
            assertThat(result[Fields.YAMATOCODE0.ordinal()], is("ya"));
            assertThat(result[Fields.YAMATOCODE1.ordinal()], is("to"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getSeikyuushoFlg_jitaku1() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setMatsujimeFlg(new BigDecimal(0));
        juchuu.setTodokesakiInd(new BigDecimal(1));
        juchuu.getKokyaku().setJitakuInd(new BigDecimal(1));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.SEIKYUUSHO_FLG.ordinal()], is("1"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getSeikyuushoFlg_seikyuusaki1() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setMatsujimeFlg(new BigDecimal(0));
        juchuu.setMatsujimeFlg(new BigDecimal(0));
        juchuu.setSeikyuusakiFlg(new BigDecimal(1));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.SEIKYUUSHO_FLG.ordinal()], is("0"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getSeikyuushoFlg_seikyuusaki2() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setMatsujimeFlg(new BigDecimal(0));
        juchuu.setSeikyuusakiFlg(new BigDecimal(2));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.SEIKYUUSHO_FLG.ordinal()], is("1"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getSeikyuushoFlg_other() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setMatsujimeFlg(new BigDecimal(0));
        juchuu.setSeikyuusakiFlg(new BigDecimal(0));
        juchuu.setSeikyuushoFlg(new BigDecimal(3));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.SEIKYUUSHO_FLG.ordinal()], is("3"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }
    @Test
    public void testCreateData_getCoolDiscount() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.getTodokesaki().getTodoufukenData().setKyakusouryou(new BigDecimal(100));
        juchuu.setSouryou(new BigDecimal(10));
        juchuu.setReitouryou(new BigDecimal(500));

        List<Juchuumeisai> juchuumeisaiList = new ArrayList<Juchuumeisai>();
        Juchuumeisai juchuumeisai1 = new Juchuumeisai();
        Shouhin shouhin1 = new Shouhin();
        shouhin1.setCoolkubun(new BigDecimal(3));
        shouhin1.setShouhin("おためし");
        shouhin1.setPointoritsu(new BigDecimal(1));
        juchuumeisai1.setShouhin(shouhin1);
        juchuumeisai1.setJuchuu(createJuchuu());
        juchuumeisai1.setSuuryou(new BigDecimal(1));
        juchuumeisai1.setBaika(new BigDecimal(100));
        juchuumeisaiList.add(juchuumeisai1);
        juchuu.setJuchuumeisais(juchuumeisaiList);
        juchuumeisai1.setJuchuu(juchuu);
        
        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.COOL_DISCOUNT.ordinal()], is("0"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getCoolDiscount_coolFlag3() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.getTodokesaki().getTodoufukenData().setKyakusouryou(new BigDecimal(100));

        List<Juchuumeisai> juchuumeisaiList = new ArrayList<Juchuumeisai>();
        Juchuumeisai juchuumeisai1 = new Juchuumeisai();
        Shouhin shouhin1 = new Shouhin();
        shouhin1.setCoolkubun(new BigDecimal(3));
        shouhin1.setShouhin("おためし");
        shouhin1.setPointoritsu(new BigDecimal(1));
        juchuumeisai1.setShouhin(shouhin1);
        juchuumeisai1.setJuchuu(createJuchuu());
        juchuumeisai1.setSuuryou(new BigDecimal(1));
        juchuumeisai1.setBaika(new BigDecimal(100));
        juchuumeisaiList.add(juchuumeisai1);
        juchuu.setJuchuumeisais(juchuumeisaiList);
        
        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.COOL_DISCOUNT.ordinal()], is("100"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getCoolDiscount_coolFlag2() {
        // Juchuu
        Juchuu juchuu = createJuchuu();

        List<Juchuumeisai> juchuumeisaiList = new ArrayList<Juchuumeisai>();
        Juchuumeisai juchuumeisai1 = createJuchuumeisai_getCoolDiscount();
        juchuumeisai1.getShouhin().setCoolkubun(new BigDecimal(1));
        juchuumeisai1.setBaika(new BigDecimal(100));
        juchuumeisaiList.add(juchuumeisai1);

        Juchuumeisai juchuumeisai2 = createJuchuumeisai_getCoolDiscount();
        juchuumeisai2.getShouhin().setCoolkubun(new BigDecimal(2));
        juchuumeisai2.setBaika(new BigDecimal(100));
        juchuumeisaiList.add(juchuumeisai2);
        juchuu.setJuchuumeisais(juchuumeisaiList);
        
        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.COOL_DISCOUNT.ordinal()], is("0"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getCoolDiscount_coolFlag2_coolSending() {
        // Juchuu
        Juchuu juchuu = createJuchuu();

        List<Juchuumeisai> juchuumeisaiList = new ArrayList<Juchuumeisai>();
        Juchuumeisai juchuumeisai1 = createJuchuumeisai_getCoolDiscount();
        juchuumeisai1.getShouhin().setCoolkubun(new BigDecimal(1));
        juchuumeisai1.setBaika(new BigDecimal(100));
        juchuumeisaiList.add(juchuumeisai1);

        Juchuumeisai juchuumeisai2 = createJuchuumeisai_getCoolDiscount();
        juchuumeisai2.getShouhin().setCoolkubun(new BigDecimal(2));
        juchuumeisai2.setBaika(new BigDecimal(100));
        juchuumeisaiList.add(juchuumeisai2);
        juchuu.setJuchuumeisais(juchuumeisaiList);
        
        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        // calendar
        TestEnvironment.setTestDate(2014, 8, 1, 7, 59, 59);

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.COOL_DISCOUNT.ordinal()], is("0"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getCoolDiscount_coolFlag4() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setJuchuuDate(getTimestamp());

        List<Juchuumeisai> juchuumeisaiList = new ArrayList<Juchuumeisai>();
        Juchuumeisai juchuumeisai1 = createJuchuumeisai_getCoolDiscount();
        juchuumeisai1.getShouhin().setCoolkubun(new BigDecimal(4));
        juchuumeisai1.setBaika(new BigDecimal(100));
        juchuumeisaiList.add(juchuumeisai1);

        juchuu.setJuchuumeisais(juchuumeisaiList);
        
        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        shouhin.put("coolkubun", "1");
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.COOL_DISCOUNT.ordinal()], is("0"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getCoolDiscount_coolFlagnot4() {
        // Juchuu
        Juchuu juchuu = createJuchuu();

        List<Juchuumeisai> juchuumeisaiList = new ArrayList<Juchuumeisai>();
        Juchuumeisai juchuumeisai1 = createJuchuumeisai_getCoolDiscount();
        juchuumeisai1.getShouhin().setCoolkubun(new BigDecimal(5));
        juchuumeisai1.setBaika(new BigDecimal(100));
        juchuumeisaiList.add(juchuumeisai1);

        juchuu.setJuchuumeisais(juchuumeisaiList);
        
        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.COOL_DISCOUNT.ordinal()], is("0"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    private Juchuumeisai createJuchuumeisai_getCoolDiscount(){
        Juchuumeisai juchuumeisai = new Juchuumeisai();
        juchuumeisai.setJuchuu(createJuchuu());
        juchuumeisai.getJuchuu().setJuchuuDate(getTimestamp());
        juchuumeisai.setSuuryou(new BigDecimal(1));
        Shouhin shouhin = new Shouhin();
        shouhin.setCoolkubun(new BigDecimal(3));
        shouhin.setShouhin("おためし");
        shouhin.setPointoritsu(new BigDecimal(1));
        juchuumeisai.setShouhin(shouhin);
        return juchuumeisai;
    }

    @Test
    public void testCreateData_processSeikyuuIdAndBarcode_ikkaiConveni(){
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setSeikyuuId("A2020103220"); // input by excel
        juchuu.setMatsujimeFlg(new BigDecimal(0));
        juchuu.setKessaiId(new BigDecimal(4));
        juchuu.setJuchuushubetsu(new BigDecimal(0));
        juchuu.setSeikyuushoFlg(new BigDecimal(0));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        // TBL_JUCHUU
        juchuu.setJuchuuId("1");
        juchuu.setKokyakuId("1");
        juchuu.setSakujoFlg(new BigDecimal(0));
        juchuu.setJuchuuDate(getTimestamp());
        juchuu.setGochiFlg(new BigDecimal(0));
        tantousha.setTantoushaId("0000");

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.COOL_DISCOUNT.ordinal()], is("0"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        } 
    }

    // this method occurs exception and writes error log on the console.
    @Test
    public void testCreateData_processSeikyuuIdAndBarcode_exception(){
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setSeikyuuId(null);
        juchuu.setMatsujimeFlg(new BigDecimal(0));
        juchuu.setKessaiId(new BigDecimal(4));
        juchuu.setJuchuushubetsu(new BigDecimal(0));
        juchuu.setSeikyuushoFlg(new BigDecimal(0));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        // TBL_JUCHUU
        juchuu.setJuchuuId("1");
        juchuu.setKokyakuId("1");
        juchuu.setSakujoFlg(new BigDecimal(0));
        juchuu.setJuchuuDate(getTimestamp());
        juchuu.setGochiFlg(new BigDecimal(0));
        tantousha.setTantoushaId("0000");
        juchuu.getKokyaku().setKokyakuId(null); // does not exist in M_KOKYAKU

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.JUCHUU_ID.ordinal()], is("1"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        } 
    }

    @Test
    public void testCreateData_getShouhindaikin_notnull() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setShouhindaikin(new BigDecimal(100));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.SHOUHINDAIKIN.ordinal()], is("100"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getCsvToutyakujikan2() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setToutyakujikanId(new BigDecimal(2));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.CSVTOUTYAKUJIKAN.ordinal()], is("12"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getCsvToutyakujikan3() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setToutyakujikanId(new BigDecimal(3));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.CSVTOUTYAKUJIKAN.ordinal()], is("14"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getCsvToutyakujikan4() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setToutyakujikanId(new BigDecimal(4));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.CSVTOUTYAKUJIKAN.ordinal()], is("16"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getCsvToutyakujikan5() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setToutyakujikanId(new BigDecimal(5));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.CSVTOUTYAKUJIKAN.ordinal()], is("18"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getCsvToutyakujikan6() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setToutyakujikanId(new BigDecimal(6));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.CSVTOUTYAKUJIKAN.ordinal()], is("20"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getCsvToutyakujikan_other() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setToutyakujikanId(new BigDecimal(0));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.CSVTOUTYAKUJIKAN.ordinal()], is(StringUtils.EMPTY));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_processYamatoCode_null() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        Yuubinbangou yuubinbangou = new Yuubinbangou();
        yuubinbangou.setYuubinbangou(null);
        juchuu.getTodokesaki().setYuubinbangou(yuubinbangou);

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.YAMATOCODE0.ordinal()], is(StringUtils.EMPTY));
            assertThat(result[Fields.YAMATOCODE1.ordinal()], is(StringUtils.EMPTY));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_processYamatoCode_jogai() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        Yuubinbangou yuubinbangou = new Yuubinbangou();
        yuubinbangou.setYuubinbangou("0040000"); // ini file
        juchuu.getTodokesaki().setYuubinbangou(yuubinbangou);

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.YAMATOCODE0.ordinal()], is(StringUtils.EMPTY));
            assertThat(result[Fields.YAMATOCODE1.ordinal()], is(StringUtils.EMPTY));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getYamatoDenpyouKubun3() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setKessaiId(new BigDecimal(3));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            hassou1Csv.setCoolSendingFlag(0);
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.YAMATODENPYOUKUBUN.ordinal()], is("3"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getYamatoDenpyouKubun4() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setKessaiId(new BigDecimal(3));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            hassou1Csv.setCoolSendingFlag(1);
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.YAMATODENPYOUKUBUN.ordinal()], is("4"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getShiyoupointo_notnull() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setShiyoupointo(new BigDecimal(2));
        juchuu.setTashaShiyouPointo(new BigDecimal(1));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.SHIYOUPOINTO.ordinal()], is("1"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getGenzaipointo() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.getKokyaku().setPointo(new BigDecimal(1));
        List<Juchuumeisai> juchuumeisaiList = new ArrayList<Juchuumeisai>();
        Juchuumeisai juchuumeisai1 = new Juchuumeisai();
        Shouhin shouhin1 = new Shouhin();
        shouhin1.setCoolkubun(new BigDecimal(0));
        shouhin1.setShouhin("おためし");
        shouhin1.setPointoritsu(new BigDecimal(1));
        juchuumeisai1.setShouhin(shouhin1);
        juchuumeisai1.setJuchuu(createJuchuu());
        juchuumeisai1.setSuuryou(new BigDecimal(1));
        juchuumeisai1.setBaika(new BigDecimal(100));
        juchuumeisaiList.add(juchuumeisai1);
        juchuu.setJuchuumeisais(juchuumeisaiList);

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.GENZAIPOINTO.ordinal()], is("2"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_isEmptySeikyuukingaku_gift() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setMatsujimeFlg(new BigDecimal(0));
        juchuu.setKessaiId(new BigDecimal(4));
        juchuu.setJuchuushubetsu(new BigDecimal(2));
        juchuu.setSeikyuushoFlg(new BigDecimal(1));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.SEIKYUUKINGAKU0.ordinal()], is(StringUtils.EMPTY));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getSeikyuukingaku_empty() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setMatsujimeFlg(new BigDecimal(0));
        juchuu.setKessaiId(new BigDecimal(4));
        juchuu.setJuchuushubetsu(new BigDecimal(1));
        juchuu.setJuchuukingaku(new BigDecimal(1234567));
        // to avoid exceptions
        juchuu.setSeikyuushoFlg(new BigDecimal(0));
        // TBL_JUCHUU
        juchuu.setJuchuuId("1");
        juchuu.setKokyakuId("1");
        juchuu.setSakujoFlg(new BigDecimal(0));
        juchuu.setJuchuuDate(getTimestamp());
        juchuu.setGochiFlg(new BigDecimal(0));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.SEIKYUUKINGAKU0.ordinal()], is(StringUtils.EMPTY));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getSeikyuukingaku_notempty() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setMatsujimeFlg(new BigDecimal(0));
        juchuu.setKessaiId(new BigDecimal(4));
        juchuu.setJuchuushubetsu(new BigDecimal(1));
        juchuu.setJuchuukingaku(new BigDecimal(1));
        // to avoid exceptions
        juchuu.setSeikyuushoFlg(new BigDecimal(0));
        // TBL_JUCHUU
        juchuu.setJuchuuId("1");
        juchuu.setKokyakuId("1");
        juchuu.setSakujoFlg(new BigDecimal(0));
        juchuu.setJuchuuDate(getTimestamp());
        juchuu.setGochiFlg(new BigDecimal(0));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();
        tantousha.setTantoushaId("0000");

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.SEIKYUUKINGAKU7.ordinal()], is("1"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getFlagOnOff19() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.getKokyaku().setTorihikisakiId(new BigDecimal(19));

        // Shouhin map list
        Map<String, Object> shouhin = createShouhinMap();
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        shouhinList.add(shouhin);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.ONOFF_FLG.ordinal()], is("1"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getPriority200() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setSouryou(new BigDecimal(0));
        juchuu.setJuchuuId("1");

        List<Juchuumeisai> juchuumeisaiList = new ArrayList<Juchuumeisai>();
        Juchuumeisai juchuumeisai1 = new Juchuumeisai();
        Shouhin shouhin1 = new Shouhin();
        shouhin1.setCoolkubun(new BigDecimal(0));
        shouhin1.setShouhin("おためし");
        shouhin1.setPointoritsu(new BigDecimal(1));
        juchuumeisai1.setShouhin(shouhin1);
        juchuumeisai1.setJuchuu(createJuchuu());
        juchuumeisai1.setSuuryou(new BigDecimal(1));
        juchuumeisai1.setBaika(new BigDecimal(100));
        juchuumeisaiList.add(juchuumeisai1);
        juchuu.setJuchuumeisais(juchuumeisaiList);


        // Shouhin map list
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        Map<String, Object> shouhinMap1 = createShouhinMap();
        shouhinMap1.put("juchuuId", "1");
        shouhinList.add(shouhinMap1);
        Map<String, Object> shouhinMap2 = createShouhinMap();
        shouhinMap2.put("juchuuId", "1");
        shouhinList.add(shouhinMap2);
        Map<String, Object> shouhinMap3 = createShouhinMap();
        shouhinMap3.put("juchuuId", "1");
        shouhinList.add(shouhinMap3);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.PRIORITY.ordinal()], is("200"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getPriority300() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setJuchuuId("1");

        List<Juchuumeisai> juchuumeisaiList = new ArrayList<Juchuumeisai>();
        Juchuumeisai juchuumeisai1 = new Juchuumeisai();
        Shouhin shouhin1 = new Shouhin();
        shouhin1.setShouhin("おまかせ");
        shouhin1.setCoolkubun(new BigDecimal(0));
        shouhin1.setPointoritsu(new BigDecimal(1));
        juchuumeisai1.setShouhin(shouhin1);
        juchuumeisai1.setJuchuu(createJuchuu());
        juchuumeisai1.setSuuryou(new BigDecimal(1));
        juchuumeisai1.setBaika(new BigDecimal(100));
        juchuumeisaiList.add(juchuumeisai1);
        juchuu.setJuchuumeisais(juchuumeisaiList);

        // Shouhin map list
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        Map<String, Object> shouhinMap1 = createShouhinMap();
        shouhinMap1.put("juchuuId", "1");
        shouhinList.add(shouhinMap1);
        Map<String, Object> shouhinMap2 = createShouhinMap();
        shouhinMap2.put("juchuuId", "1");
        shouhinList.add(shouhinMap2);
        Map<String, Object> shouhinMap3 = createShouhinMap();
        shouhinMap3.put("juchuuId", "1");
        shouhinList.add(shouhinMap3);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.PRIORITY.ordinal()], is("300"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getPriority500() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setJuchuuId("1");
        juchuu.getTodokesaki().setTodoufukenId(new BigDecimal(1));

        // Shouhin map list
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        Map<String, Object> shouhinMap1 = createShouhinMap();
        shouhinMap1.put("juchuuId", "1");
        shouhinList.add(shouhinMap1);
        Map<String, Object> shouhinMap2 = createShouhinMap();
        shouhinMap2.put("juchuuId", "1");
        shouhinList.add(shouhinMap2);
        Map<String, Object> shouhinMap3 = createShouhinMap();
        shouhinMap3.put("juchuuId", "1");
        shouhinList.add(shouhinMap3);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.PRIORITY.ordinal()], is("500"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getPriority600() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setJuchuuId("1");
        juchuu.getTodokesaki().setTodoufukenId(new BigDecimal(8));
        juchuu.getTodokesaki().setAddr1("");

        // Shouhin map list
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        Map<String, Object> shouhinMap1 = createShouhinMap();
        shouhinMap1.put("juchuuId", "1");
        shouhinList.add(shouhinMap1);
        Map<String, Object> shouhinMap2 = createShouhinMap();
        shouhinMap2.put("juchuuId", "1");
        shouhinList.add(shouhinMap2);
        Map<String, Object> shouhinMap3 = createShouhinMap();
        shouhinMap3.put("juchuuId", "1");
        shouhinList.add(shouhinMap3);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.PRIORITY.ordinal()], is("600"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getPriority700() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setJuchuuId("1");
        juchuu.getTodokesaki().setTodoufukenId(new BigDecimal(8));
        juchuu.getTodokesaki().setAddr1("横浜市");

        // Shouhin map list
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        Map<String, Object> shouhinMap1 = createShouhinMap();
        shouhinMap1.put("juchuuId", "1");
        shouhinList.add(shouhinMap1);
        Map<String, Object> shouhinMap2 = createShouhinMap();
        shouhinMap2.put("juchuuId", "1");
        shouhinList.add(shouhinMap2);
        Map<String, Object> shouhinMap3 = createShouhinMap();
        shouhinMap3.put("juchuuId", "1");
        shouhinList.add(shouhinMap3);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.PRIORITY.ordinal()], is("700"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getPriority800() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setJuchuuId("1");

        // Shouhin map list
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        Map<String, Object> shouhinMap1 = createShouhinMap();
        shouhinMap1.put("juchuuId", "1");
        shouhinMap1.put("coolkubun", "4");
        shouhinList.add(shouhinMap1);

        // Tantousha
        Tantousha tantousha = createTantousha();

        // set reitouryouFlag; this test pattern uses.
        Hassou1Csv hassou1Csv = new Hassou1Csv();
        hassou1Csv.setReitouryouFlg(1);

        try {
            // execute
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.PRIORITY.ordinal()], is("800"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getPriority1000() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setJuchuuId("1");
        juchuu.setJuchuuDate(getTimestamp("2008/01/01"));

        List<Juchuumeisai> juchuumeisaiList = new ArrayList<Juchuumeisai>();
        Juchuumeisai juchuumeisai1 = new Juchuumeisai();
        Shouhin shouhin1 = new Shouhin();
        shouhin1.setShouhin("おまかせ");
        shouhin1.setPointoritsu(new BigDecimal(1));
        juchuumeisai1.setShouhin(shouhin1);
        juchuumeisai1.getShouhin().setCoolkubun(new BigDecimal(4));
        juchuumeisai1.setJuchuu(createJuchuu());
        juchuumeisai1.setSuuryou(new BigDecimal(1));
        juchuumeisai1.setBaika(new BigDecimal(100));
        juchuumeisaiList.add(juchuumeisai1);
        juchuu.setJuchuumeisais(juchuumeisaiList);

        // Shouhin map list
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        Map<String, Object> shouhinMap1 = createShouhinMap();
        shouhinList.add(shouhinMap1);


        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.PRIORITY.ordinal()], is("1000"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getPriority1100() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.getTodokesaki().setTodoufukenId(new BigDecimal(1));
        juchuu.setJuchuuId("1");

        // Shouhin map list
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        Map<String, Object> shouhinMap1 = createShouhinMap();
        shouhinMap1.put("juchuuId", "2");
        shouhinList.add(shouhinMap1);

        // Tantousha
        Tantousha tantousha = createTantousha();

        // set reitouryouFlag; this test pattern uses.
        Hassou1Csv hassou1Csv = new Hassou1Csv();
        hassou1Csv.setReitouryouFlg(1);

        try {
            // execute
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.PRIORITY.ordinal()], is("1100"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getPriority1200() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.getTodokesaki().setTodoufukenId(new BigDecimal(8));
        juchuu.getTodokesaki().setAddr1("");
        juchuu.setJuchuuId("1");

        // Shouhin map list
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        Map<String, Object> shouhinMap1 = createShouhinMap();
        shouhinMap1.put("juchuuId", "2");
        shouhinList.add(shouhinMap1);

        // Tantousha
        Tantousha tantousha = createTantousha();

        // set reitouryouFlag; this test pattern uses.
        Hassou1Csv hassou1Csv = new Hassou1Csv();
        hassou1Csv.setReitouryouFlg(1);

        try {
            // execute
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.PRIORITY.ordinal()], is("1200"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testCreateData_getPriority1300() {
        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.getTodokesaki().setTodoufukenId(new BigDecimal(0));

        // Shouhin map list
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        Map<String, Object> shouhinMap1 = createShouhinMap();
        shouhinMap1.put("juchuuId", "1");
        shouhinList.add(shouhinMap1);

        // Tantousha
        Tantousha tantousha = createTantousha();

        // set reitouryouFlag; this test pattern uses.
        Hassou1Csv hassou1Csv = new Hassou1Csv();
        hassou1Csv.setReitouryouFlg(1);

        try {
            // execute
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0, tantousha);
            assertThat(result[Fields.PRIORITY.ordinal()], is("1300"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testGetShouhinDiscount_tax005() {
        // tax 5%
        TestEnvironment.setTestDate(2014, 4, 1, 7, 59, 59);

        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setJuchuuId("1");
        juchuu.setJuchuuDate(DateUtil.toTimestamp(DateUtil.getDate()));

        List<Juchuumeisai> juchuumeisaiList = new ArrayList<Juchuumeisai>();
        Juchuumeisai juchuumeisai1 = new Juchuumeisai();
        juchuumeisai1.setTeika(new BigDecimal(300));
        juchuumeisai1.setSuuryou(new BigDecimal(1));
        juchuumeisai1.setBaika(new BigDecimal(100));
        // not to occur exceptions
        Shouhin shouhin1 = new Shouhin();
        shouhin1.setShouhin("おまかせ");
        shouhin1.setPointoritsu(new BigDecimal(1));
        juchuumeisai1.setShouhin(shouhin1);
        juchuumeisai1.getShouhin().setCoolkubun(new BigDecimal(4));
        juchuumeisai1.setJuchuu(createJuchuu());
        juchuumeisaiList.add(juchuumeisai1);
        juchuu.setJuchuumeisais(juchuumeisaiList);

        // Shouhin map list
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        Map<String, Object> shouhinMap1 = createShouhinMap();
        shouhinList.add(shouhinMap1);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0,
                    tantousha);
            assertThat(result[Fields.SHOUHIN_DISCOUNT.ordinal()], is("210"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testGetShouhinDiscount_tax008() {
        // tax 5%
        TestEnvironment.setTestDate(2014, 4, 1, 8, 0, 0);

        // Juchuu
        Juchuu juchuu = createJuchuu();
        juchuu.setJuchuuId("1");
        juchuu.setJuchuuDate(DateUtil.toTimestamp(DateUtil.getDate()));

        List<Juchuumeisai> juchuumeisaiList = new ArrayList<Juchuumeisai>();
        Juchuumeisai juchuumeisai1 = new Juchuumeisai();
        juchuumeisai1.setTeika(new BigDecimal(300));
        juchuumeisai1.setSuuryou(new BigDecimal(1));
        juchuumeisai1.setBaika(new BigDecimal(100));
        // not to occur exceptions
        Shouhin shouhin1 = new Shouhin();
        shouhin1.setShouhin("おまかせ");
        shouhin1.setPointoritsu(new BigDecimal(1));
        juchuumeisai1.setShouhin(shouhin1);
        juchuumeisai1.getShouhin().setCoolkubun(new BigDecimal(4));
        juchuumeisai1.setJuchuu(createJuchuu());
        juchuumeisaiList.add(juchuumeisai1);
        juchuu.setJuchuumeisais(juchuumeisaiList);

        // Shouhin map list
        List<Map<String, Object>> shouhinList = new ArrayList<Map<String, Object>>();
        Map<String, Object> shouhinMap1 = createShouhinMap();
        shouhinList.add(shouhinMap1);

        // Tantousha
        Tantousha tantousha = createTantousha();

        try {
            // execute
            Hassou1Csv hassou1Csv = new Hassou1Csv();
            String[] result = hassou1Csv.createData(juchuu, shouhinList, 0,
                    tantousha);
            assertThat(result[Fields.SHOUHIN_DISCOUNT.ordinal()], is("216"));
        } catch (IOException e) {
            e.printStackTrace();
            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        } catch (BusinessException e) {
            e.printStackTrace();
            fail();
        }
    }

    @Test
    public void testGetData(){
        Hassou1Csv hassou1Csv = new Hassou1Csv();
        String[] result = hassou1Csv.getData();
        assertNull(result);
    }

    @Test
    public void testGetCoolSendingFlag(){
        Hassou1Csv hassou1Csv = new Hassou1Csv();
        int result = hassou1Csv.getCoolSendingFlag();
        assertThat(String.valueOf(result), is("0"));
    }

    @Test
    public void testGetReitouryouFlg(){
        Hassou1Csv hassou1Csv = new Hassou1Csv();
        int result = hassou1Csv.getReitouryouFlg();
        assertThat(String.valueOf(result), is("0"));
    }

    private Juchuu createJuchuu(){
        Juchuu juchuu = new Juchuu();
        juchuu.setJuchuuId("juchuuId");
        juchuu.setKessaiId(new BigDecimal(99));
        juchuu.setKokyakuId("kokyakuId");
        juchuu.setKokyaku(createKokyaku());
        juchuu.setTodokesaki(createTodokesaki());
        juchuu.setJuchuumeisais(new ArrayList<Juchuumeisai>());
        juchuu.setMatsujimeFlg(new BigDecimal(1));
        juchuu.setJuchuushubetsu(new BigDecimal(2));
        juchuu.setReitouryou(new BigDecimal(0));
        juchuu.setCoolryou(new BigDecimal(0));
        juchuu.setToutyakuyoteiDate(getTimestamp());
        juchuu.setToutyakujikanId(new BigDecimal(1));
        juchuu.setJihikiFlg(new BigDecimal(0));
        juchuu.setSeikyuusakiFlg(new BigDecimal(0));
        juchuu.setSouryou(new BigDecimal(0));
        juchuu.getTodokesaki().setTodoufukenData(createTodoufuken());
        juchuu.setHassouyoteiDate(getTimestamp());
        juchuu.setJuchuuDate(DateUtil.getTimestamp());
        return juchuu;
    }

    private Kokyaku createKokyaku() {
        Kokyaku kokyaku = new Kokyaku();
        kokyaku.setShimei("shimei");
        kokyaku.setTodoufukenId(new BigDecimal(11));
        kokyaku.setJitakuInd(new BigDecimal(0));
        kokyaku.setKokyakuId("01000001"); // M_KOKYAKU
        return kokyaku;
    }
    private Todokesaki createTodokesaki(){
        Todokesaki todokesaki = new Todokesaki();
        todokesaki.setPk(createTodokesakiPK());
        return todokesaki;
    }
    private TodokesakiPK createTodokesakiPK(){
        TodokesakiPK todokesakiPk = new TodokesakiPK();
        return todokesakiPk;
    }
    private Todoufuken createTodoufuken(){
        Todoufuken todoufuken = new Todoufuken();
        todoufuken.setKyakusouryou(new BigDecimal(0));
        return todoufuken;
    }
    private Map<String, Object> createShouhinMap(){
        Map<String, Object> shouhin = new HashMap<String, Object>();
        shouhin.put("juchuuId", "juchuuId");
        return shouhin;
    }

    private Tantousha createTantousha(){
        Tantousha tantousha = new Tantousha();
        return tantousha;
    }


    private Timestamp getTimestamp(){
        return getTimestamp(null);
    }

    private Timestamp getTimestamp(String str) {
        Timestamp dateTime = null;
        try {
            String dateTimeStr = str;
            if (str == null) {
                dateTimeStr = "2014/01/01";
            }
            Long dateTimeLong = new SimpleDateFormat("yyyy/MM/dd")
                    .parse(dateTimeStr).getTime();
            dateTime = new Timestamp(dateTimeLong);

        } catch (Exception e) {
            e.printStackTrace();
        }

        return dateTime;
    }

}
